package com.demoAnnotation;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;


public class AnnotationTest {
    @MyTest()
    public void test1(){
        System.out.println("=====test1====");
    }

    @MyTest
    public void test2(){
        System.out.println("=====test2====");
    }
    public static void main(String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        AnnotationTest a = new AnnotationTest();
        Class c =AnnotationTest.class;
        Method[] methods = c.getDeclaredMethods();
        for (Method method : methods) {
            if(method.isAnnotationPresent(MyTest.class)){
                //存在

                method.invoke(a);
            }
        }
    }

}

